#include "head.h"



int main()
{
    int socket_fd=get_tcp_socket();
    int new_fd;
    struct sockaddr_in client_addr;//对客户端进行初始化
    bzero(&client_addr,sizeof(client_addr));
    socklen_t addr_len=sizeof(client_addr);
    while (1)
    {
        new_fd=accept(socket_fd,(struct sockaddr *)&client_addr,&addr_len);//连接，产生用于通信的new_fd
        ERROR_CHECK(new_fd,-1,"accept")
        printf("CONNECT SUCCESS!\n");
        ptrain_t pt=(ptrain_t)malloc(sizeof(train_t));
        pt->fd=new_fd;
        if(!fork())
        {
            child_op(pt);
            return 0;
        }
        free (pt);     
    }
    return 0;
    
}